#version 110
uniform sampler2D tex;
+uniform float startY;
uniform float fraction;
uniform float height;
const float c = -0.2;
// To reduce contrast, blend with a mid gray
cogl_color_out = color * contrast - off * c;
- // We only fully dim at a distance of BORDER_MAX_HEIGHT from the edge and
+ // We only fully dim at a distance of BORDER_MAX_HEIGHT from startY and
// when the fraction is 1.0. For other locations and fractions we linearly
- // interpolate back to the original undimmed color.
- cogl_color_out = color + (cogl_color_out - color) * min(y / border_max_height, 1.0);
+ // interpolate back to the original undimmed color, so the top of the window
+ // is at full color.
+ cogl_color_out = color + (cogl_color_out - color) * max(min((y - startY) / border_max_height, 1.0), 0.0);
cogl_color_out = color + (cogl_color_out - color) * fraction;
cogl_color_out *= color.a;
return dimShader;
}
-function WindowDimmer(actor) {
- this._init(actor);
+function getTopInvisibleBorder(metaWindow) {
+ let outerRect = metaWindow.get_outer_rect();
+ let inputRect = metaWindow.get_input_rect();
+ return outerRect.y - inputRect.y;
+}
+
+function WindowDimmer(actor, window) {
+ this._init(actor, window);
}
WindowDimmer.prototype = {
- _init: function(actor) {
+ _init: function(actor, window) {
this.effect = new Clutter.ShaderEffect({ shader_type: Clutter.ShaderType.FRAGMENT_SHADER });
this.effect.set_shader_source(getDimShaderSource());
+ this.window = window;
this.actor = actor;
},
}
if (fraction > 0.01) {
+ Shell.shader_effect_set_double_uniform(this.effect, 'startY', getTopInvisibleBorder(this.window));
Shell.shader_effect_set_double_uniform(this.effect, 'height', this.actor.get_height());
Shell.shader_effect_set_double_uniform(this.effect, 'fraction', fraction);
_dimFraction: 0.0
};
-function getWindowDimmer(texture) {
+function getWindowDimmer(texture, window) {
if (!texture._windowDimmer)
- texture._windowDimmer = new WindowDimmer(texture);
+ texture._windowDimmer = new WindowDimmer(texture, window);
return texture._windowDimmer;
}
return;
let texture = actor.get_texture();
if (animate)
- Tweener.addTween(getWindowDimmer(texture),
+ Tweener.addTween(getWindowDimmer(texture, window),
{ dimFraction: 1.0,
time: DIM_TIME,
transition: 'linear'
});
else
- getWindowDimmer(texture).dimFraction = 1.0;
+ getWindowDimmer(texture, window).dimFraction = 1.0;
},
_undimWindow: function(window, animate) {
return;
let texture = actor.get_texture();
if (animate)
- Tweener.addTween(getWindowDimmer(texture),
+ Tweener.addTween(getWindowDimmer(texture, window),
{ dimFraction: 0.0,
time: UNDIM_TIME,
transition: 'linear'
});
else
- getWindowDimmer(texture).dimFraction = 0.0;
+ getWindowDimmer(texture, window).dimFraction = 0.0;
},
_mapWindow : function(shellwm, actor) {